import { createRouter, createWebHashHistory } from 'vue-router'

/* Layout */
import Layout from '@/layout'
export const constantRoutes = [
  {
    path: "/loading",
    component: () => import(`@/views/loading/loading.vue`),
    meta: { title: "知识登录", permission: "loading" },
    hidden: true
  },
  {
    path: "/login",
    component:()=>import('@/views/login/index'),
    hidden: true
  },
  {
    path: "/register",
    component:()=>import('@/views/login/register'),
    hidden: true
  },
  {
    path: "/forgetface",
    component:()=>import('@/views/login/forgetFace'),
    hidden: true
  },
  {
    path: "/",
    component: Layout,
    redirect: "/dashboard",
    hidden: true
  },

  {
    path: "/:pathMatch(.*)*",
    name:'404',
    component: ()=>import('@/views/404.vue'),
    hidden: true
  },

  // 404 page must be placed at the end !!!
  // { path: "*", redirect: "/404", hidden: true }
];
export const asyncRoutes = [
 

  // 仪表盘
  {
    path: "",
    name: "Dashboard",
    component: Layout,
    redirect: "/dashboard",
    meta: {
      title: "首页",
      icon: "dashboard"
    },
    children: [
      {
        path: "/dashboard",
        name: "dashboard",
        component:()=> import('@/views/userStatistics/index'),
        meta: {
          title: "首页",
          icon: "dashboard"
        }
      }
    ]
  },
  // 基础数据维护
  {
    path: "/basicData",
    component: Layout,
    name: "BasicData",
    meta: {
      authority: ["basic_data"],
      title: "基础数据维护",
      icon: "basicData"
    },
    alwaysShow: true,
    children: [
      {
        path: "department",
        name: "basic_data_department",
        component: ()=> import("@/views/basicData/department/index"),
        meta: {
          authority: ["basic_data_department"],
          title: "科室信息维护"
        }
      },
      {
        path: "personnel",
        name: "basic_data_personnel",
        component: ()=> import("@/views/basicData/personnel/index"),
        meta: {
          authority: ["basic_data_personnel"],
          title: "人员信息维护"
        }
      },
      {
        path: "medicalWasteProduced",
        name: "basic_data_medicalWasteProduced",
        component: ()=> import("@/views/basicData/medicalWasteProduced/index"),
        meta: {
          authority: ["basic_data_medicalWasteProduced"],
          title: "医废暂存点维护"
        }
      },
      {
        path: "einheit",
        name: "device_einheit",
        component: ()=>import("@/views/basicData/einheit/index"),
        meta: {
          authority: ["basic_data_einheit"],
          title: "单位信息维护"
        }
      }
    ]
  },
  //   视频监控
  {
    path: "/videoSurveillance",
    component: Layout,
    name: "videoSurveillance",
    meta: {
      authority: ["video_surveillance"],
      title: "视频监控",
      icon: "video"
    },
    alwaysShow: true,
    children: [
      {
        path: "index",
        name: "basic_data_videoSurveillance",
        component: ()=>import("@/views/videoSurveillance/index"),
        meta: {
          authority: ["equipment_list"],
          title: "视频监控"
        }
      }
    ]
  },
  // 设备管理
  {
    path: "/equipment",
    component: Layout,
    name: "Equipment",
    meta: {
      authority: ["equipment"],
      title: "设备管理",
      icon: "equipment"
    },
    alwaysShow: true,
    children: [
      {
        path: "equipmentList",
        name: "basic_data_equipmentList",
        component: ()=>import("@/views/equipment/equipmentList/index"),
        meta: {
          authority: ["equipment_list"],
          title: "设备列表"
        }
      },
      {
        path: "matchingPersonnel",
        name: "basic_data_matchingPersonnel",
        component: ()=>import("@/views/equipment/matchingPersonnel/index"),
        meta: {
          authority: ["basic_data_matchingPersonnel"],
          title: "设备匹配人员"
        }
      },
      {
        path: "deviceType",
        name: "basic_data_deviceType",
        component: ()=>import("@/views/equipment/deviceType/index"),
        meta: {
          authority: ["equipment_type"],
          title: "设备类型"
        }
      }
    ]
  },
  // 耗材管理
  {
    path: "/consumable",
    component: Layout,
    name: "Consumable",
    meta: {
      authority: ["consumable"],
      title: "耗材管理",
      icon: "consumable"
    },
    alwaysShow: true,
    children: [
      {
        path: "consumableList",
        name: "basic_data_consumableList",
        component: ()=>import("@/views/consumable/consumableList/index"),
        meta: {
          authority: ["consumable_list"],
          title: "耗材列表"
        }
      },
      {
        path: "inventory",
        name: "basic_data_inventory",
        component: ()=>import("@/views/consumable/inventory/index"),
        meta: {
          authority: ["consumable_inventory"],
          title: "耗材申领"
        }
      }
    ]
  },
  
   // 医废管理
   {
    path: "/medicalWasteAdmin", 
    component: Layout,
    name: "MedicalWasteAdmin",
    meta: {
      authority: ["medicalWasteAdmin"],
      title: "医废管理",
      icon: "medicalWaste"
    },
    alwaysShow: true,
    children: [
      {
        path: "report",
        name: "MedicalWasteAdmin_basic_data_report",
        component:  ()=>import("@/views/medicalWasteAdmin/report/index"),
        meta: {
          authority: ["basic_data_report"],
          title: "医废报表"
        }
      },
      {
        path: "gatherStatistics",
        name: "MedicalWasteAdmin_basic_data_gatherStatistics",
        component: ()=>import("@/views/medicalWasteAdmin/gatherStatistics/index"),
        meta: {
          authority: ["basic_data_gatherStatistics"],
          title: "医废收集统计"
        }
      },
      {
        path: "encoding",
        name: "MedicalWasteAdmin_basic_data_encoding",
        component: ()=>import("@/views/medicalWasteAdmin/encoding/index"),
        meta: {
          authority: ["basic_data_encoding"],
          title: "医废编码"
        }
      },
      {
        path: "retrospect",
        name: "MedicalWasteAdmin_basic_data_retrospect",
        component: ()=>import("@/views/medicalWasteAdmin/retrospect/index"),
        meta: {
          authority: ["basic_data_retrospect"],
          title: "医疗废物追溯"
        }
      }
    ]
  },
  // 医废管理
  {
    path: "/medicalWaste",
    component: Layout,
    name: "MedicalWaste",
    meta: {
      authority: ["medicalWaste"], 
      title: "医废管理",
      icon: "medicalWaste"
    },
    alwaysShow: true,
    children: [
      {
        path: "report",
        name: "basic_data_report",
        component: ()=>import("@/views/medicalWaste/report/index"),
        meta: {
          authority: ["basic_data_report"],
          title: "医废报表"
        }
      },
      {
        path: "gatherStatistics",
        name: "basic_data_gatherStatistics",
        component: ()=>import("@/views/medicalWaste/gatherStatistics/index"),
        meta: {
          authority: ["basic_data_gatherStatistics"],
          title: "医废收集统计"
        }
      },
      {
        path: "encoding",
        name: "basic_data_encoding",
        component: ()=>import("@/views/medicalWaste/encoding/index"),
        meta: {
          authority: ["basic_data_encoding"],
          title: "医废编码"
        }
      },
      {
        path: "retrospect",
        name: "basic_data_retrospect",
        component: ()=>import("@/views/medicalWaste/retrospect/index"),
        meta: {
          authority: ["basic_data_retrospect"],
          title: "医疗废物追溯"
        }
      }
    ]
  },
  // 报警信息
  {
    path: "/alarmInfo",
    component: Layout,
    name: "AlarmInfo",
    meta: {
      authority: ["alarm_info"],
      title: "预警信息",
      icon: "alarmInfo"
    },
    alwaysShow: true,
    children: [
      {
        path: "alarmRecord",
        name: "basic_data_alarmRecord",
        component: ()=>import("@/views/alarmInfo/alarmRecord/index"),
        meta: {
          authority: ["basic_data_alarmRecord"],
          title: "预警记录"
        }
      },
      {
        path: "alarmRules",
        name: "_TTbasic_data_alarmRules",
        component: ()=>import("@/views/alarmInfo/alarmRules/index"),
        meta: {
          authority: ["basic_data_alarmRules"],
          title: "预警规则"
        }
      }
    ]
  },
  // 系统管理
  {
    path: "/setting",
    component: Layout,
    name: "Setting",
    meta: {
      authority: ["systeam"],
      title: "系统管理",
      icon: "setting"
    },
    alwaysShow: true,
    children: [
      {
        path: "users",
        name: "basic_data_users",
        component: ()=>import("@/views/setting/users/index"),
        meta: {
          authority: ["systeam_users"],
          title: "用户管理"
        }
      },
      {
        path: "userAdmin",
        name: "basic_data_user_admin",
        component: ()=>import("@/views/setting/userAdmin/index"),
        meta: {
          authority: ["systeam_user_admin"],
          title: "管理员管理"
        }
      },
      {
        path: "roles",
        name: "basic_data_roles",
        component: ()=>import("@/views/setting/roles/index"),
        meta: {
          authority: ["systeam_roles"],
          title: "角色管理"
        }
      },
      {
        path: "menus",
        name: "basic_data_menus",
        component: ()=>import("@/views/setting/menus/index"),
        meta: {
          authority: ["systeam_menus"],
          title: "菜单管理"
        }
      },
      {
        path: "dictionaries",
        name: "basic_data_dictionaries",
        component: ()=>import("@/views/setting/dictionaries/index"),
        meta: {
          authority: ["systeam_dictionaries"],
          title: "字典管理"
        }
      },
      {
        path: "versionUpgrade",
        name: "basic_data_versionUpgrade",
        component: ()=>import("@/views/setting/versionUpgrade/index"),
        meta: {
          authority: ["systeam_versionUpgrade"],
          title: "版本管理"
        }
      }
    ]
  },
  //通知公告
  {
    path: "/notification",
    component: Layout,
    name: "Notification",
    meta: {
      authority: ["notification"],
      title: "通知公告",
      icon: "notification"
    },
    alwaysShow: true,
    children: [
      {
        path: "index",
        name: "basic_data_users",
        component: ()=>import("@/views/notification/index"),
        meta: {
          authority: ["notification_list"],
          title: "通知公告"
        }
      }
    ]
  },

  // 医院机构管理
  {
    path: "/hospitalInstitutions",
    component: Layout,
    name: "HospitalInstitutions",
    meta: {
      authority: ["hospital_info"],
      title: "医院机构管理",
      icon: "hospitalInstitutions"
    },
    alwaysShow: true,
    children: [
      {
        path: "index",
        name: "hospital_index",
        component: ()=>import(
            "@/views/hospitalInstitutions/hospitalInstitutionsList/index"
          ),
        meta: {
          authority: ["hospital_index"],
          title: "医院机构管理"
        }
      },
      {
        path: "application",
        name: "basic_data_alarmRules",
        component: ()=>import("@/views/hospitalInstitutions/application/index"),
        meta: {
          authority: ["hospital_application"],
          title: "医院机构申请列表"
        }
      }
    ]
  },
  // 404 page must be placed at the end !!!
];


const router = createRouter({
  history: createWebHashHistory(),
  routes:[ ...constantRoutes,...asyncRoutes]
})

export default router
